package ljl.alg.wangzheng_camp.round1.veryveryeasy;

public class _offer_5_replace_space {
    
    /**
     * 像这种题我没啥动力挨个替换
     * */
    public String replaceSpace2(String s) {
        return s.replace(" ", "%20");
    }
    
    
    /**
     * 算了写一下吧
    * */
    public String replaceSpace(String s) {
        StringBuilder sb = new StringBuilder(s.length() * 2);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ')
                sb.append("%20");
            else sb.append(s.charAt(i));
        }
        return sb.toString();
    }
}
